home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00067_Script_MenuPrincipal < prev    next >
Text File  |  1999-03-19  |  15KB  |  511 lines

  1. property spr -- the spriteNum of me
  2. property escondido -- Se esta escondido
  3. property ativo -- Se mouse esta por cima do menu este esta ativo
  4. property menuSel -- Opcao do menu selecionada
  5. property subMenu -- Submenu aberto
  6. property submenuSel -- Opcao dos submenus selecionada
  7. property ligado
  8. property x_ini, y_ini -- Quando desligado, aonde estava menu
  9. property lado
  10.  
  11. on beginSprite me
  12.   -- Inicializacao
  13.   set ativo = false
  14.   set spr = the spriteNum of me
  15.   set ligado = true
  16.   set escondido = false
  17.   set the visibility of sprite (spr+1) to true
  18.   set menuSel = 0
  19.   set subMenu = 0
  20.   set submenuSel = 0
  21.   set lado = 0
  22.   -- Desliga outros menus
  23.   sendSprite(97,#chaveVisibilidade,false)
  24.   sendSPrite(97,#moveRelativo, 500,0)
  25.   
  26.   -- Desliga opcoes ainda nao selecionadas desse menu
  27.   repeat with i = 3 to 7
  28.     set the visibility of sprite (spr+i) to false
  29.   end repeat
  30.   
  31. end
  32.  
  33. on moveDireitaEsquerda me
  34.   set d = the width of sprite spr
  35.   repeat with i = 3 to 7
  36.     set x = the locH of sprite (spr+i)
  37.     set dx = the width of sprite (spr+i)
  38.     set the locH of sprite (spr+i) to x - d - dx
  39.   end repeat
  40.   set lado = 1
  41. end
  42.  
  43. on moveEsquerdaDireita me
  44.   set d = the width of sprite spr
  45.   repeat with i = 3 to 7
  46.     set x = the locH of sprite (spr+i)
  47.     set dx = the width of sprite (spr+i)
  48.     set the locH of sprite (spr+i) to x + d + dx
  49.   end repeat
  50.   set lado = 0 
  51. end  
  52.  
  53. on decideEsquerdaDireita me
  54.   if the locH of sprite spr > 400 then 
  55.     set l = 1
  56.   else 
  57.     set l = 0
  58.   end if
  59.   
  60.   if l <> lado then
  61.     if lado = 1 then
  62.       moveEsquerdaDireita me
  63.     else
  64.       moveDireitaEsquerda me
  65.     end if
  66.   end if
  67. end 
  68.  
  69. -- Mostra/esconde menu principal, fazendo sumir a parte debaixo
  70. on mostraEsconde me
  71.   puppetSound 2, "Esconde"
  72.   if escondido then
  73.     -- Volta a mostrar
  74.     set escondido = false
  75.     set the visibility of sprite spr+1 to true
  76.     updateStage
  77.   else
  78.     -- Esconde
  79.     set escondido = true
  80.     if subMenu <> 0 then
  81.       set the visibility of sprite (subMenu+spr+3) to false
  82.       set subMenu = 0
  83.     end if   
  84.     if the colorDepth > 8 then
  85.       set ini = the timer
  86.       global gCritico
  87.       set gCritico = gCritico + 1
  88.       repeat while (the timer - ini) < 100
  89.         set blend = 100 - (the timer - ini)
  90.         if blend < 0 then set blend = 0
  91.         set the blend of sprite (spr+1) to blend
  92.         updateStage
  93.         sendAllSprites(#idleSprite)
  94.       end repeat
  95.       set gCritico = gCritico - 1
  96.       set the blend of sprite (spr+1) to 100
  97.     end if
  98.     set the visibility of sprite spr+1 to false
  99.     updateStage
  100.   end if
  101. end
  102.  
  103.  
  104. -- Abre/Fecha animando bolinha
  105. on abreFecha me
  106.   if ligado then
  107.     puppetSound 2,"Aciona"
  108.     
  109.     -- Remove estado ativado (mouse sobre popup)
  110.     if ativo then
  111.       global gCritico
  112.       set gCritico = gCritico - 1
  113.       set ativo = false
  114.       set the member of sprite spr to member "MPTitulo: Desativado"
  115.       if not escondido then
  116.         set the member of sprite (spr+1) to member "MenuPrincipal: Desativado"
  117.       end if
  118.     end if
  119.     -- Desliga sprites
  120.     repeat with i = spr to spr+8
  121.       set the visibility of sprite i to false
  122.     end repeat
  123.     -- Movimenta bola
  124.     set x_fim = 67
  125.     set y_fim = 80
  126.     set x_ini = the locH of sprite (spr+9)
  127.     set y_ini = the locV of sprite (spr+9)
  128.     set x = x_ini
  129.     set y = y_ini
  130.     set dist = sqrt( (x_fim-x_ini) * (x_fim - x_ini) +¼
  131.                          (y_fim-y_ini) * (y_fim - y_ini) )
  132.     set tempo = dist
  133.     if tempo > 30 then set tempo = 30
  134.     set tmp = the timer
  135.     repeat while tmp + tempo > the timer
  136.       set dist = (the timer - tmp) * 10000 / tempo
  137.       set novoy = sqrt(dist)*(y_fim - y_ini)/100 + y_ini
  138.       set novox = dist*(x_fim-x_ini)/10000 + x_ini
  139.       
  140.       sendSprite(spr+2, #moveRelativo, novox-x, novoy-y)
  141.       set x = novox
  142.       set y = novoy
  143.       updateStage
  144.     end repeat
  145.     sendSprite(spr+2, #moveRelativo, x_fim - x, y_fim - y)
  146.     updateStage
  147.     set ligado = false
  148.   else
  149.     puppetSound 2, "Aciona"
  150.     -- Religa, primeiro movendo botao para lugar de origem
  151.     set x_fim = x_ini
  152.     set y_fim = y_ini
  153.     set x_ini = the locH of sprite (spr+9)
  154.     set y_ini = the locV of sprite (spr+9)
  155.     set x = x_ini
  156.     set y = y_ini
  157.     set dist = sqrt( (x_fim-x_ini) * (x_fim - x_ini) +¼
  158.                          (y_fim-y_ini) * (y_fim - y_ini) )
  159.     set tempo = dist*2
  160.     if tempo > 20 then set tempo = 20
  161.     set tmp = the timer
  162.     repeat while tmp + tempo > the timer
  163.       set dist = (the timer - tmp) * 10000 / tempo
  164.       set novoy = sqrt(dist)*(y_fim - y_ini)/100 + y_ini
  165.       set novox = dist*(x_fim-x_ini)/10000 + x_ini
  166.       sendSprite(spr+2, #moveRelativo, novox-x, novoy-y)
  167.       set x = novox
  168.       set y = novoy
  169.       updateStage
  170.     end repeat
  171.     sendSprite(spr+2, #moveRelativo, x_fim - x, y_fim - y)
  172.     set ligado = true
  173.     set the visibility of sprite spr to true
  174.     set the visibility of sprite (spr+2) to true
  175.     if not escondido then set the visibility of sprite (spr+1) to true
  176.     updateStage
  177.   end if
  178.   
  179. end
  180.  
  181.  
  182. -- Click no menu principal
  183. on mouseUp me
  184.   cursor 4
  185.   sendSprite(spr, #idleSprite)
  186.   
  187.   
  188.   if menuSel = 0 then
  189.     -- Click no Titulo
  190.     set mh = the mouseH - the locH of sprite spr
  191.     if mh > 48 then
  192.       -- Click no mostra/esconde
  193.       mostraEsconde me
  194.     else
  195.       -- Click na bolinha, liga/desliga janela
  196.       abreFecha me      
  197.     end if
  198.     
  199.   else 
  200.     puppetSound 2, "SomCliqueSimples"
  201.     -- Apresentacao
  202.     if menuSel = 1 then
  203.       if submenuSel = 0 then
  204.         if (subMenu <> 0) then
  205.           set the visibility of sprite (spr+subMenu+3) to false
  206.           set the visibility of sprite (spr+8) to false
  207.         end if
  208.         if (subMenu <> 4) then
  209.           set subMenu = 4
  210.           set the visibility of sprite (spr+7) to true
  211.           set the visibility of sprite (spr+8) to false
  212.           --        decideEsquerdaDireita me
  213.         else
  214.           set subMenu = 0
  215.         end if
  216.       else 
  217.         set the visibility of sprite (spr+subMenu+3) to false
  218.         set the visibility of sprite (spr+8) to false
  219.         set subMenu = 0
  220.         -- Search generico
  221.         global gPronde, gDonde
  222.         set gPronde = 0
  223.         calculaDonde
  224.         if gDonde <> 0 then
  225.           sendAllSprites(#cleanSprite)
  226.         end if
  227.         sendSprite(112,#moveRelativo,18 - the locH of sprite 112,¼
  228.                167 - the locV of sprite 112)
  229.         case subMenuSel of
  230.           400:
  231.             go frame "Introducao"
  232.           401:
  233.             go frame "Help"
  234.         end case
  235.       end if
  236.       
  237.       -- Criadores
  238.     else if menuSel =2 then
  239.       if (subMenu <> 0) then
  240.         set the visibility of sprite (spr+subMenu+3) to false
  241.         set the visibility of sprite (spr+8) to false
  242.         set subMenu = 0
  243.       end if
  244.       global gPronde
  245.       set gPronde = 1000
  246.       sendAllSprites(#cleanSprite)
  247.       calculaDonde
  248.       vaiCriadores 0
  249.       
  250.       -- Revista heroi
  251.     else if menuSel = 3 then
  252.       if (subMenu <> 0) then
  253.         set the visibility of sprite (spr+subMenu+3) to false
  254.         set the visibility of sprite (spr+8) to false
  255.         set subMenu = 0
  256.       end if
  257.       global gPronde
  258.       set gPronde = 2000
  259.       sendAllSprites(#cleanSprite)
  260.       calculaDonde
  261.       go frame "Melhores Momentos"
  262.       
  263.       -- Searches
  264.     else if menuSel = 6 then
  265.       if submenuSel = 0 then
  266.         if (subMenu <> 0) then
  267.           set the visibility of sprite (spr+subMenu+3) to false
  268.         end if
  269.         if (subMenu <> 1) then
  270.           set subMenu = 1
  271.           set the visibility of sprite (spr+4) to true
  272.         else
  273.           set subMenu = 0
  274.         end if
  275.       else 
  276.         set the visibility of sprite (spr+subMenu+3) to false
  277.         set the visibility of sprite (spr+8) to false
  278.         set subMenu = 0
  279.         -- Search generico
  280.         case subMenuSel of
  281.           100:
  282.             sendSprite(97,#chaveVisibilidade,true)
  283.             sendSprite(97,#setEstado,0)
  284.           101:
  285.             sendSprite(97,#chaveVisibilidade,true)
  286.             sendSprite(97,#setEstado,1)          
  287.           102: 
  288.             sendSprite(97,#chaveVisibilidade,true)
  289.             sendSprite(97,#setEstado,2)
  290.         end case
  291.         
  292.       end if
  293.       
  294.       -- Universos
  295.     else if menuSel = 4 then
  296.       if submenuSel = 0 then
  297.         if (subMenu <> 0) then
  298.           set the visibility of sprite (spr+subMenu+3) to false
  299.           set the visibility of sprite (spr+8) to false
  300.         end if
  301.         if (subMenu <> 2) then
  302.           set subMenu = 2
  303.           set the visibility of sprite (spr+5) to true
  304.           set the visibility of sprite (spr+8) to false
  305.         else
  306.           set subMenu = 0
  307.         end if
  308.         
  309.       else
  310.         -- Vai para universo
  311.         set universos = [7, 4, 3, 2, 1, 5,6]
  312.         set tmp = getAt(universos,subMenuSel - 199)
  313.         
  314.         set the visibility of sprite (spr+subMenu+3) to false
  315.         set the visibility of sprite (spr+8) to false
  316.         set subMenu = 0
  317.         set subMenuSel = 0
  318.         
  319.         sendSprite 120, #comecaAnima
  320.         updateStage
  321.         global gPronde
  322.         set gPronde = 1
  323.         calculaDonde
  324.         sendAllSprites(#cleanSprite)
  325.         go frame "Universo"
  326.         sendSprite 21, #vaiIcone, tmp
  327.         sendSprite 120, #finalizaAnima
  328.         updateStage
  329.       end if
  330.       
  331.       
  332.       -- Verbetes
  333.     else if menuSel = 5 then
  334.       -- put submenuSel
  335.       if submenuSel = 0 then 
  336.         if (subMenu <> 0) then
  337.           set the visibility of sprite (spr+subMenu+3) to false
  338.           set the visibility of sprite (spr+8) to false
  339.         end if
  340.         if (subMenu <> 3) then
  341.           set subMenu = 3
  342.           set the visibility of sprite (spr+6) to true
  343.           set the visibility of sprite (spr+8) to false
  344.         else
  345.           set subMenu = 0
  346.         end if
  347.       else
  348.         global gAstroAtual, gEquipeAtual, gHeroiAtual
  349.         if submenuSel = 300 then
  350.           set tmp = gHeroiAtual
  351.         else if submenuSel = 301 then
  352.           set tmp = gEquipeAtual
  353.         else if submenuSel = 302 then
  354.           set tmp = gAstroAtual
  355.         end if      
  356.         
  357.         set submenuSel = 0
  358.         set subMenu = 0
  359.         set the visibility of sprite (spr+6) to false
  360.         set the visibility of sprite (spr+8) to false
  361.         
  362.         vaiPagina tmp, true
  363.       end if
  364.       
  365.       -- Saida
  366.     else if menuSel = 7 then
  367.       if (subMenu <> 0) then
  368.         set the visibility of sprite (spr+subMenu+3) to false
  369.         set the visibility of sprite (spr+8) to false
  370.         set subMenu = 0
  371.       end if
  372.       sendSprite 120, #chaveSaida, true
  373.     end if
  374.   end if
  375.   
  376.   cursor -1
  377. end
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384. -- Idle sprite
  385. --  tmp = novo valor de ativo
  386. --  tmp2 = novo valor de menuSel
  387. --  tmp3 = novo valor de submenuSel
  388. on idleSprite me
  389.   if not ligado then return
  390.   
  391.   global gMustUpdate, gCritico
  392.   
  393.   if rollOver(spr) or ¼
  394.     ((not escondido) and rollOver(spr+1)) then
  395.     set tmp = true
  396.     if escondido then
  397.       set tmp2 = 0
  398.       set tmp3 = 0
  399.     else
  400.       put the mouseV into y
  401.       put y - (the locV of sprite spr - 55) into y
  402.       set tmp2 = y/16
  403.       set tmp3 = 0
  404.     end if
  405.   else
  406.     set tmp = false
  407.     set tmp2 = 0
  408.     set tmp3 = 0
  409.   end if
  410.   
  411.   -- Submenu busca
  412.   if subMenu = 1 and rollOver(spr+4) then
  413.     set tmp = true
  414.     set tmp2 = 6
  415.     put the mouseV into y
  416.     put y - (the locV of sprite (spr+4) + 39) into y
  417.     set tmp3 = y/16 + 100
  418.   end if
  419.   
  420.   -- Submenu universos
  421.   if subMenu = 2 and rollOver(spr+5) then
  422.     set tmp = true
  423.     set tmp2 = 4
  424.     put the mouseV into y
  425.     put y - (the locV of sprite (spr+5) - 30) into y
  426.     set tmp3 = y/16 + 200
  427.   end if
  428.   
  429.   -- Submenu verbetes
  430.   if subMenu = 3 and rollOver(spr+6) then
  431.     set tmp = true
  432.     set tmp2 = 5
  433.     put the mouseV into y
  434.     put y - (the locV of sprite (spr+6) + 6) into y
  435.     set tmp3 = y/16 + 300
  436.   end if
  437.   
  438.   -- Submenu apresentacao
  439.   if subMenu = 4 and rollOver(spr+7) then
  440.     set tmp = true
  441.     set tmp2 = 1
  442.     put the mouseV into y
  443.     put y - (the locV of sprite (spr+7) - 10) into y
  444.     set tmp3 = y/16 + 400
  445.   end if
  446.   
  447.   
  448.   -- Se mudou o estado do menu
  449.   if (tmp <> ativo) then
  450.     set ativo = tmp
  451.     set gMustUpdate = true
  452.     if ativo then
  453.       set the member of sprite spr to member "MPTitulo: Ativado"
  454.       if not escondido then
  455.         set the member of sprite (spr+1) to member "MenuPrincipal: Ativado"
  456.       end if
  457.       set gCritico = gCritico + 1
  458.     else
  459.       set the member of sprite spr to member "MPTitulo: Desativado"
  460.       if not escondido then
  461.         set the member of sprite (spr+1) to member "MenuPrincipal: Desativado"
  462.       end if
  463.       set the visibility of sprite (spr+3) to false
  464.       set menuSel = 0
  465.       set gCritico = gCritico - 1
  466.       if subMenu <> 0 then
  467.         set the visibility of sprite (subMenu+spr+3) to false
  468.         set the visibility of sprite (spr+8) to false
  469.         set subMenu = 0
  470.       end if     
  471.     end if
  472.   end if
  473.   
  474.   -- Verifica se mudou opcao selecionada do menu
  475.   if tmp2 <> menuSel then
  476.     set gMustUpdate = true
  477.     set menuSel = tmp2
  478.     if menuSel = 0 then
  479.       set the visibility of sprite (spr+3) to false
  480.     else
  481.       set the member of sprite (spr+3) to member¼
  482.             ((the number of member "Ativos MenuPrincipal") - 1 + menuSel)
  483.       set the visibility of sprite (spr+3) to true
  484.     end if
  485.   end if
  486.   
  487.   -- Verifica opcao selecionada em submenus
  488.   if tmp3 <> submenuSel then
  489.     set gMustUpdate = true
  490.     set submenuSel = tmp3
  491.     if submenuSel = 0 then
  492.       set the visibility of sprite (spr+8) to false
  493.     else
  494.       if submenuSel < 200 then
  495.         set the member of sprite (spr+8) to member¼
  496.         ((the number of member "SubMenu Ativo Search")-100 +submenuSel)
  497.       else if submenuSel < 300 then
  498.         set the member of sprite (spr+8) to member¼
  499.         ((the number of member "SubMenu Ativo Universo")-200 +submenuSel)
  500.       else if submenuSel < 400 then
  501.         set the member of sprite (spr+8) to member¼
  502.         ((the number of member "SubMenu Ativo Verbete")-300 +submenuSel) 
  503.       else
  504.         set the member of sprite (spr+8) to member¼
  505.         ((the number of member "SubMenu Ativo Apresentacao")-400 +submenuSel)
  506.       end if
  507.       updateStage
  508.       set the visibility of sprite (spr+8) to true
  509.     end if
  510.   end if
  511. end